package cn.okcode.slowjson.internal;

/**
 * @author pyk13
 */
public class CharUtils {

    public static boolean isDigit(char chr) {
        return chr <= '9' && chr >= '0';
    }

    public static boolean isSign(char chr) {
        return chr == '-' || chr == '+';
    }

    public static boolean isDot(char chr) {
        return chr == '.';
    }

    public static boolean isAlpha(char chr) {
        return chr <= 'Z' && chr >= 'A' || chr <= 'z' && chr >= 'a';
    }

    public static boolean isSpace(char chr) {
        return chr == ' ';
    }

    public static boolean isTab(char chr) {
        return chr == '\t';
    }

    /**
     * 空格 制表符 回车
     *
     * @param chr 待判断字符
     * @return true：空，false：非空
     */
    public static boolean isEmpty(char chr) {
        return isSpace(chr) || isTab(chr);
    }

    public static boolean isNewLine(char chr) {
        return chr == '\r' || chr == '\n';
    }

    public static boolean isDigitOrAlpha(char chr) {
        return isDigit(chr) || isAlpha(chr);
    }

}
